package string;

public class StringOp {
    public static void main(String[] args) {
        String s1 = "ABCde";
        String s2 = "bc";
        System.out.println("字符串s1为：" + s1);
        System.out.println("字符串s1的长度为：" + s1.length());
        System.out.println("字符串s2为：" + s2);
        System.out.println("字符串s2的长度为:" + s2.length());
        System.out.println("s1的大写形式是：" + s1.toUpperCase());
        System.out.println("s2的小写形式是：" + s2.toLowerCase());
        for (int i = 0; i < s1.length(); i++) {
            System.out.println("s1中的第" + i + "个字符是：" + s1.charAt(i));
        }
        System.out.println("s1+s2="+s1+s2);
        if (s1.compareTo(s2)==0){
            System.out.println("s1与s2相等");
        }
        else{
            System.out.println("s1与s2不相等");
        }
        if (s1.indexOf(s2)!=-1){
            System.out.println("s2是s1的子串");
            System.out.println("s2在s1中的位置为："+s1.indexOf(s2));
        }
        else {
            System.out.println("s2不是s1的子串");
            System.out.println("经过以上操作，s1与s2没有变化：");
            System.out.println("字符串s1仍然为："+s1);
            System.out.println("字符串s1仍然为："+s2);
        }





    }
}
